package com.example.vspm.mapper;

import com.example.vspm.entity.Person;
import com.example.vspm.entity.Receiver;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;

@Mapper
@Repository
public interface PersonMapper {

    //登录///// 根据用户名或手机号 //查询获取登录后的pid
    @Select("select tid from vspm_person where (personName=#{personName} or telephone=#{personName})" +
            " and  password = #{password}")
    @Options(useGeneratedKeys = true, keyProperty = "tid", keyColumn = "tid")
    Integer loginPerson(Person person);

    //登录用map验证,正在实验中
    @Select("select * from vspm_person where (personName=#{personName} or telephone=#{personName})" +
            " and  password = #{password})")
    @Options(useGeneratedKeys = true, keyProperty = "tid", keyColumn = "tid")
    Person logPerson(@Param("personName") String personName, @Param("password") String password);


    //注册
    @Insert("insert into vspm_person(personName,password,telephone,unitCompany,capacity) values(#{personName},#{password},#{telephone},#{unitCompany},#{capacity})")
    void insertPerson(Person person);


    ////根据id获取对象
    @Select(value = "select * from vspm_person where tid=#{tid}")
    Person findPerson(@Param("tid") int tid);

    //测试vue获取对象
    @Select(value = "select * from vspm_person ")
    Person selectPerson();




}